﻿<UserControl
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:editorControls="clr-namespace:Levfier.GUI.EditorControls"
        xmlns:menuLabels="clr-namespace:Levfier.GUI.MenuLabels"
        xmlns:gui="clr-namespace:Levfier.GUI"
        xmlns:avalonDock="http://schemas.xceed.com/wpf/xaml/avalondock"
        mc:Ignorable="d"
        x:Class="Levfier.GUI.MainWindow" Width="800" Height="600" Focusable="true">

    <!--スタイルテンプレート読み込み-->
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <!--Dark Theme-->
                <ResourceDictionary Source="../Themes/Metro/Dark/MetroDark.MSControls.Core.Implicit.xaml" />
                <!--<ResourceDictionary Source="../Dark/MetroDark.MSControls.Toolkit.Implicit.xaml" />-->
            </ResourceDictionary.MergedDictionaries>

            <Style x:Key="AvalonDock_ThemeMetro_AnchorablePaneControlStyle" TargetType="{x:Type avalonDock:LayoutAnchorablePaneControl}">
                <Setter Property="TabStripPlacement" Value="Bottom"/>
                <Setter Property="Padding" Value="0,6,0,0"/>
                <Setter Property="BorderThickness" Value="0"/>
                <Setter Property="Foreground" Value="{Binding Model.Root.Manager.Foreground, RelativeSource={RelativeSource Self}}"/>
                <Setter Property="Background" Value="{Binding Model.Root.Manager.Background, RelativeSource={RelativeSource Self}}"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type avalonDock:LayoutAnchorablePaneControl}">
                            <Grid ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>
                                <!--Following border is required to catch mouse events-->
                                <Border Background="Transparent" Grid.RowSpan="2"/>
                                <Border x:Name="ContentPanel" 
                                BorderBrush="{TemplateBinding BorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Background="{TemplateBinding Background}" 
                                Grid.Column="0" 
                                KeyboardNavigation.DirectionalNavigation="Contained"
                                Grid.Row="0" 
                                KeyboardNavigation.TabIndex="2" 
                                KeyboardNavigation.TabNavigation="Cycle">
                                    <ContentPresenter x:Name="PART_SelectedContentHost"
                                              ContentSource="SelectedContent" 
                                              Margin="{TemplateBinding Padding}"
                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                </Border>
                                <avalonDock:AnchorablePaneTabPanel x:Name="HeaderPanel" Margin="0,0,0,2" IsItemsHost="true" Grid.Row="1" KeyboardNavigation.TabIndex="1" Panel.ZIndex="1"/>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsEnabled" Value="false">
                                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                                </Trigger>
                                <DataTrigger Binding="{Binding Items.Count, RelativeSource={RelativeSource Self}}" Value="1">
                                    <Setter Property="Margin" Value="0" TargetName="HeaderPanel"/>
                                </DataTrigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>

                <Setter Property="ItemContainerStyle">
                    <Setter.Value>
                        <Style TargetType="{x:Type TabItem}">
                            <Setter Property="Background" Value="Transparent"/>
                            <Setter Property="BorderBrush" Value="Transparent"/>
                            <Setter Property="Foreground" Value="{DynamicResource AvalonDock_ThemeMetro_BaseColor5}"/>
                            <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
                            <Setter Property="ToolTip" Value="{Binding ToolTip}"/>
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type TabItem}">
                                        <Grid SnapsToDevicePixels="true">
                                            <Border x:Name="Bd" 
							              BorderBrush="{TemplateBinding BorderBrush}"
                                          Margin="4"
   				                          BorderThickness="0" 
							              Background="{TemplateBinding Background}" 
							              Padding="{TemplateBinding Padding}">
                                                <ContentPresenter 
								            x:Name="Content" 
								            ContentSource="Header" 
                                            HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" 
                                            VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"
                                            RecognizesAccessKey="True" 
                                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                            </Border>
                                        </Grid>
                                        <ControlTemplate.Triggers>
                                            <Trigger Property="Selector.IsSelected"
								            Value="true">
                                                <Setter Property="BorderBrush"
									        Value="{DynamicResource AvalonDock_ThemeMetro_BaseColor5}" />
                                                <Setter Property="Panel.ZIndex" 
                                            Value="1" />
                                            </Trigger>

                                            <DataTrigger Binding="{Binding IsActive}" Value="True">
                                                <Setter Property="BorderBrush"
									        Value="{DynamicResource AvalonDock_ThemeMetro_BaseColor3}" />
                                                <Setter Property="Foreground" Value="{DynamicResource AvalonDock_ThemeMetro_BaseColor5}"/>
                                                <Setter Property="Panel.ZIndex" 
                                            Value="1" />
                                            </DataTrigger>
                                            <MultiTrigger>
                                                <MultiTrigger.Conditions>
                                                    <Condition Property="IsMouseOver" Value="true"/>
                                                    <Condition Property="Selector.IsSelected" Value="false"/>
                                                </MultiTrigger.Conditions>
                                                <Setter Property="BorderBrush" Value="{DynamicResource AvalonDock_ThemeMetro_BaseColor4}"/>
                                                <Setter Property="Panel.ZIndex" Value="0" />
                                            </MultiTrigger>
                                            <Trigger Property="IsEnabled" Value="false">
                                                <Setter Property="BorderBrush" Value="{DynamicResource AvalonDock_ThemeMetro_BaseColor13}"/>
                                                <Setter Property="Background" Value="{DynamicResource AvalonDock_ThemeMetro_BaseColor9}"/>
                                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                                            </Trigger>
                                        </ControlTemplate.Triggers>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type TabControl}}, Path=Items.Count}" Value="1">
                                    <Setter Property="Visibility" Value="Collapsed"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Setter.Value>
                </Setter>

                <Setter Property="ItemTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <avalonDock:LayoutAnchorableTabItem Model="{Binding}"/>
                        </DataTemplate>
                    </Setter.Value>
                </Setter>

                <Setter Property="ContentTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <avalonDock:LayoutAnchorableControl Model="{Binding}"/>
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <DataTemplate x:Key="AvalonDock_ThemeMetro_AnchorableTitleTemplate">
                <TextBlock Text="{Binding Title}" TextTrimming="CharacterEllipsis" Margin="6,0,0,0"/>
            </DataTemplate>

            <!--ドッキングマネージャのレイアウトをAnchorablePaneにも適用する-->
            <Style x:Key="{x:Type avalonDock:DockingManager}" TargetType="{x:Type avalonDock:DockingManager}">
                <Setter Property="AnchorablePaneControlStyle" Value="{StaticResource AvalonDock_ThemeMetro_AnchorablePaneControlStyle}"/>
                <Setter Property="AnchorableTitleTemplate" Value="{StaticResource AvalonDock_ThemeMetro_AnchorableTitleTemplate}"/>

            </Style>

            <Style TargetType="MenuItem">
                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="Background" Value="#00aade"/>
                    </Trigger>
                </Style.Triggers>
            </Style>

        </ResourceDictionary>
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="22"/>
            <RowDefinition />
        </Grid.RowDefinitions>
        <Menu Grid.Row="0" HorizontalAlignment="Stretch" Height="22" VerticalAlignment="Top" Background="{DynamicResource ButtonBackgroundBrush}" BorderThickness="0" Foreground="{x:Null}">
            <!--<Menu.Resources>
                <Style TargetType="MenuItem">
                    <Style.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" Value="#00aade"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </Menu.Resources>-->

            <MenuItem Header="File" Foreground="{DynamicResource Brush03}">
                <MenuItem Header="Save" Click="SaveMenu_Click" Foreground="{DynamicResource Brush05}" />
                <MenuItem Header="Load" Click="LoadMenu_Click" Foreground="{DynamicResource Brush05}"/>
            </MenuItem>
        </Menu>

        <avalonDock:DockingManager Grid.Row="1" x:Name="dockingManager" Foreground="{DynamicResource Brush03}" Background="#FF323232">
            <!--<avalonDock:DockingManager.Theme>
                <avalonDock:MetroTheme/>
            </avalonDock:DockingManager.Theme>-->
            <avalonDock:LayoutRoot>
                <avalonDock:LayoutPanel Orientation="Horizontal">
                    <avalonDock:LayoutPanel Orientation="Vertical" DockWidth="200">

                        <!--*************************************************************-->
                        <avalonDock:LayoutAnchorablePane>
                            <avalonDock:LayoutAnchorable Title="Proccessors" CanClose="False" CanAutoHide="False" CanHide="False">
                                <!--プロセッサのリスト-->
                                <ScrollViewer HorizontalScrollBarVisibility="Auto">
                                    <StackPanel AllowDrop="true">
                                        <Expander Header="Gain">
                          
                                            <StackPanel x:Name="gainStack"/>
                                        </Expander>
                                        <Expander Header="Clipper">
                                            <StackPanel x:Name="clipperStack">
                                            </StackPanel>
                                        </Expander>
                                        <Expander Header="EQ">
                                            <StackPanel x:Name="eqStack">
                                            </StackPanel>
                                        </Expander>
                                        <Expander Header="Filter">
                                            <StackPanel x:Name="filterStack">
                                            </StackPanel>
                                        </Expander>
                                        <Expander Header="Arithmetic">
                                            <StackPanel x:Name="arithmeticStack">
                                            </StackPanel>
                                        </Expander>
                                        <Expander Header="Noise Reduction">
                                            <StackPanel x:Name="noiseStack">
                                            </StackPanel>
                                        </Expander>
                                        <Expander Header="Measuring">
                                            <StackPanel x:Name="measuringStack">
                                            </StackPanel>
                                        </Expander>
                                        <Expander Header="Parameter" Visibility="Hidden">
                                            <StackPanel x:Name="paramStack">
                                            </StackPanel>
                                        </Expander>
                                    </StackPanel>
                                </ScrollViewer>
                            </avalonDock:LayoutAnchorable>
                        </avalonDock:LayoutAnchorablePane>

                        <!--*************************************************************-->
                        <avalonDock:LayoutAnchorablePane DockMinHeight="200">
                            <avalonDock:LayoutAnchorable Title="Proccessor Parameters" CanClose="False" CanAutoHide="False" CanHide="False">
                                <!--選択されたプロセッサのプロパティ-->
                                <Border x:Name="propertyArea" BorderBrush="{DynamicResource ButtonPressedBorderBrush}" BorderThickness="1" Visibility="Hidden">
                                    <Border.Background>
                                        <SolidColorBrush Color="#FF181818"/>
                                    </Border.Background>
                                </Border>
                            </avalonDock:LayoutAnchorable>
                        </avalonDock:LayoutAnchorablePane>
                        
                        <!--*************************************************************-->
                    </avalonDock:LayoutPanel>
                    
                    <!--*************************************************************-->
                    <avalonDock:LayoutPanel Orientation="Vertical" DockWidth="600" DockMinWidth="600">
                        <avalonDock:LayoutAnchorablePane DockWidth="600" DockMinWidth="600" DockHeight="480" DockMinHeight="480">
                            <avalonDock:LayoutAnchorable Title="Edit Panel" CanClose="False" CanAutoHide="False" CanHide="False">

                                <!--エディターキャンバス-->
                                <Grid Background="{DynamicResource ButtonBackgroundBrush}">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="32"/>
                                        <RowDefinition/>
                                    </Grid.RowDefinitions>
                                    <StackPanel Grid.Row="0" Orientation="Horizontal">
                                        <ToggleButton x:Name="chainButton" Content="Chain" Width="75" Click="ChainButton_Click"/>
                                        <ToggleButton x:Name="gridButton" Content="Grid" Width="75" IsChecked="True"/>
                                        <Button x:Name="deleteButton" Content="Delete" HorizontalAlignment="Left" Margin="100,0,0,0" VerticalAlignment="Top" Width="75" Height="32" Click="DeleteButton_Click"/>
                                    </StackPanel>

                                    <!--キャンバスはバックグラウンドカラーが無いとイベントが発生しない-->
                                    <Canvas Grid.Row="1"  x:Name="ampEditCanvas" Focusable="True"  AllowDrop="True" Drop="Canvas_Drop" MouseRightButtonDown="Canvas_MouseRightButtonDown" Background="#FF272727"/>
                                    <!--<Canvas Grid.Row="1" x:Name="propertyEditCanvas" AllowDrop="True" Margin="10,0,0,0" Panel.ZIndex="100"/>-->
                                </Grid>
                            </avalonDock:LayoutAnchorable>
                        </avalonDock:LayoutAnchorablePane>

                        <!--*************************************************************-->
                        <avalonDock:LayoutAnchorablePane DockHeight="80">
                            <avalonDock:LayoutAnchorable Title="Main Parameters" CanClose="False" CanAutoHide="False" CanHide="False">
                                <editorControls:MainParameterControl x:Name="mainParameterStack" Background="#FF181818"/>
                            </avalonDock:LayoutAnchorable>
                        </avalonDock:LayoutAnchorablePane>
                        <!--*************************************************************-->
                    
                    </avalonDock:LayoutPanel>
                </avalonDock:LayoutPanel>

                <avalonDock:LayoutRoot.LeftSide>
                    <avalonDock:LayoutAnchorSide>
                        <avalonDock:LayoutAnchorGroup>
                        </avalonDock:LayoutAnchorGroup>
                    </avalonDock:LayoutAnchorSide>
                </avalonDock:LayoutRoot.LeftSide>

                <avalonDock:LayoutRoot.RightSide>
                    <avalonDock:LayoutAnchorSide>
                        <avalonDock:LayoutAnchorGroup>
                        </avalonDock:LayoutAnchorGroup>
                    </avalonDock:LayoutAnchorSide>
                </avalonDock:LayoutRoot.RightSide>

            </avalonDock:LayoutRoot>
        </avalonDock:DockingManager>

    </Grid>
</UserControl>